﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AME.WebAppCore
{
    /// <summary>
    /// 用特性标记完成Service自动注入
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, Inherited = true)]
    public class AutoDI : Attribute
    {
        public ServiceLifetime LifeTime { get; set; }

        public bool IsIntfaceExist { get; set; } = false;

        /// <summary>
        /// 自动注入
        /// </summary>
        public AutoDI()
        {
        }

        /// <summary>
        /// 自动注入
        /// </summary>
        /// <param name="type">声明生命周期</param>
        public AutoDI(ServiceLifetime lifetime)
        {
            LifeTime = lifetime;
        }

        /// <summary>
        /// 自动注入
        /// </summary>
        /// <param name="type">声明生命周期</param>
        /// <param name="isIntfaceExist">是否有接口注入</param>
        public AutoDI(ServiceLifetime lifetime, bool isIntfaceExist)
        {
            LifeTime = lifetime;
            IsIntfaceExist = isIntfaceExist;
        }
    }
}
